import React, { useEffect } from "react";
import { useSelector, useDispatch } from "react-redux";
import { pushData, getDataAsync } from "./store/modules/list";

const List = () => {
  const list = useSelector((state) => state.list.list);
  const dispatch = useDispatch();

  useEffect(() => {
    dispatch(getDataAsync());
  }, [dispatch]);

  return (
    <>
      <ul>
        {list.map((item) => (
          <li key={item._id}>{item.title}</li>
        ))}
      </ul>
      <button onClick={() => dispatch(pushData(4))}>btn</button>
    </>
  );
};

export default List;
